package com.campus.secondhand.entity;

import java.time.LocalDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.Data;

/**
 * 评价实体类
 */
@Data
@Entity
@Table(name = "reviews", uniqueConstraints = {
        @UniqueConstraint(columnNames = { "order_id", "reviewer_id" })
})
public class Review {
    /**
     * 评价ID，主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 订单ID，关联orders表
     */
    @Column(name = "order_id", nullable = false)
    private Long orderId;

    /**
     * 商品ID，关联products表
     */
    @Column(name = "product_id", nullable = false)
    private Long productId;

    /**
     * 评价人ID，关联users表
     */
    @Column(name = "reviewer_id", nullable = false)
    private Long reviewerId;

    /**
     * 被评价人ID，关联users表
     */
    @Column(name = "reviewed_id", nullable = false)
    private Long reviewedId;

    /**
     * 评分（1-5星）
     */
    @Column(nullable = false)
    private Integer rating;

    /**
     * 评价内容
     */
    @Column(columnDefinition = "text")
    private String content;

    /**
     * 评价时间
     */
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;
}